﻿using System.Data.Entity.ModelConfiguration;
using INSE6260.OnlineBanking.Model;
using INSE6260.OnlineBanking.Model.Clients;

namespace INSE6260.OnlineBanking.Repository.EF.Mappings
{
    public class ClientTypeConfiguration : EntityTypeConfiguration<Client>
    {
        public ClientTypeConfiguration()
        {
            this.HasKey(t => t.Id);
            this.ToTable("Client");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.FirstName).HasColumnName("FirstName").IsRequired().IsUnicode(false).HasMaxLength(50);
            this.Property(t => t.LastName).HasColumnName("LastName").IsRequired().IsUnicode(false).HasMaxLength(50);
            this.Property(t => t.Email).HasColumnName("Email").IsRequired().IsUnicode(false).HasMaxLength(50);
            this.Property(t => t.Address).HasColumnName("Address").IsRequired().IsUnicode(false).HasMaxLength(500);
            this.Property(t => t.Telephone).HasColumnName("Telephone").IsRequired().IsUnicode(false).HasMaxLength(50);
            this.Property(t => t.OccupationTypeId).HasColumnName("OccupationTypeId");
            this.Property(t => t.EmploymentTypeId).HasColumnName("EmploymentTypeId");
            this.Property(t => t.Gender).HasColumnName("Gender");
            this.HasRequired(t => t.EmploymentType).WithMany(t => t.Clients).HasForeignKey(d => d.EmploymentTypeId);
            this.HasRequired(t => t.OccupationType).WithMany(t => t.Clients).HasForeignKey(d => d.OccupationTypeId);
        }
    }
}
